import diff from './diff'
export default class Component {
  constructor(props) {
    this.props = props
  }
  setState(state) {
    this.state = Object.assign({}, this.state, state)
    // 获取最新的要渲染的virtualDOM对象
    const virtualDOM = this.render()
    // 获取旧的 virtualDOM 对象进行比对
    const oldDOM = this.getDOM()
    // 获得旧节点的父元素容器
    const container = oldDOM.parentNode
    // 实现对象
    diff(virtualDOM, container, oldDOM)
  }
  setDOM(dom) {
    this._dom = dom
  }
  getDOM() {
    return this._dom
  }
  updateProps(props) {
    this.props = props
  }
  componentWillMount(){}
  componentDidMount(){}
  componentWillReceiveProps(nextProps){}
  shouldComponentUpdate(nextProps, nextState){
    return nextProps != this.props || nextState != this.state
  }
  componentWillUpdate(nextProps, nextState){}
  componentDidUpdate(prevProps, preState){}
  componentWillUnmount(){}
 }
